//index.js
//获取应用实例
var app = getApp()
Page({
  data: {
    default_id: 0,
    addressList:[]
  },

  selectTap: function (e) {
    console.log(e)
    let _this = this,
      address_id = e.currentTarget.dataset.id;
    _this.setData({
      default_id: parseInt(address_id)
    });
    app._post_form('address/setDefault', {
      address_id
    }, function (result) {
      _this.data.options.from === 'flow' && wx.navigateBack();
    });
    return false;
  },

  addAddess : function () {
    wx.navigateTo({
      url:"/pages/address/add"
    })
  },
  
  editAddess: function (e) {
    wx.navigateTo({
      url: "/pages/address/detail?address_id=" + e.currentTarget.dataset.id
    })
  },
  
  onLoad: function () {
    console.log('onLoad')
    this.data.options = options;
   
  },
  onShow : function () {
    this.initShippingAddress();
  },

  initShippingAddress: function () {
    var that = this;
    app._get('address/lists', {}, res=>{
      that.setData({
        addressList: res.data.list,
        default_id: res.data.default_id
      });
    })
  }

})
